package com.kone.unitylib;

import com.jd.open.api.sdk.DefaultJdClient;
import com.jd.open.api.sdk.JdClient;
import com.jd.open.api.sdk.JdException;
import com.unity3d.player.UnityPlayerActivity;
import android.os.Bundle;
import android.util.Log;

import jd.union.open.order.query.request.OrderReq;
import jd.union.open.order.query.request.UnionOpenOrderQueryRequest;
import jd.union.open.order.query.response.UnionOpenOrderQueryResponse;

public class MainActivity extends UnityPlayerActivity {

    String server_url = "https://router.jd.com/api";
    String appKey = "68aa707f4ac14b8fa15cdf7eb1ed0598";
    String appSecret = "f60e0345adf54fb39b4535f5adac85d2";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    public String Test()
    {
        Log.v("test success!!", "aaaaa");
        return  "test success";
    }
    public String TestJdQuery()
    {
        JdClient client = new DefaultJdClient(server_url, "", appKey, appSecret);
        UnionOpenOrderQueryRequest request = new UnionOpenOrderQueryRequest();
        OrderReq orderreq = new OrderReq();
        orderreq.setPageNo(1);
        orderreq.setPageSize(3);
        orderreq.setType(1);
        orderreq.setTime("201910011010");
        request.setOrderReq(orderreq);
        try {
            UnionOpenOrderQueryResponse response = client.execute(request);
            return  response.getMessage();
        }
        catch (JdException ex)
        {
            return  ex.getErrMsg();
        }
    }
}
